import request from '../http/request'
import {ref,reactive,onMounted} from 'vue'
/****************获取json模拟数据************ */
// 会员卡统计
export const statisticsMemberCardInfo=(data,total) => {
        print(data,'会员卡统计')
    return request({
        url: '/statistics_membercard/list',
        method: 'get',
        params:{data,total},
    });
};
//收费统计
export const statisticsCharge=(data) => {
        print(data,'收费统计')
        if(data.time=="month"){
             return request({
                url: `/statistics_charge/month?year=${data.year}`,
                method: 'get',
                data:data
            })
        }else if(data.time=="season"){
             return request({
                url: `/statistics_charge/quarter?year=${data.year}`,
                method: 'get',
                data:data
            })
        }else if(data.time=="year"){
             return request({
                url: `/statistics_charge/year?year1=${data.startYear}&year2=${data.endYear}`,
                method: 'get',
                data:data
            })
        }
   
}

//课次数统计
export const statisticsClassCount=(data) => {
        print(data,'课次数统计')
        if(data.time=="month"){
             return request({
                url: '/statistics_totcourse/month',
                method: 'post',
                data:data
            })
        }else if(data.time=="season"){
             return request({
                url: '/statistics_totcourse/quarter',
                method: 'post',
                data:data
            })
        }else if(data.time=="year"){
             return request({
                url: '/statistics_totcourse/year',
                method: 'post',
                data:data
            })
        }
}

export const statisticsAddAndStream=(data) => {
        print(data,'新增与流失统计')
        if(data.time=="month"){
             return request({
                url: '/statistics_customer/month',
                method: 'post',
                data:data
            })
        }else if(data.time=="season"){
             return request({
                url: '/statistics_customer/quarter',
                method: 'post',
                data:data
            })
        }else if(data.time=="year"){
             return request({
                url: '/statistics_customer/year',
                method: 'post',
                data:data
            })
        }
}

export const useYear = () => {
   
    const yearRange=ref([])//动态生成年份范围
    const generateYearRange=()=>{
        const currentYear = new Date().getFullYear();
        for (let i = currentYear; i >= currentYear - 10; i--) {
            yearRange.value.push(i);
        }
    }

     onMounted(async () => {
        generateYearRange()
    }) 
    return{yearRange}
}

// 打印参数
const print=(data,msg)=>{
 console.group('%c%s', 'color:blue', `${new Date().getTime()}  的获取${msg}信息----------`)
    console.log('分页参数', data)
    console.groupEnd()
}
